#include <SoftwareSerial.h>
#define INPUT_SIZE 30
#define EYELIGHT 9

SoftwareSerial servoSerial(10, 11); // RX, TX
char input[INPUT_SIZE + 1];
int i=0;
  
void setup() {
  pinMode(EYELIGHT, OUTPUT);
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  servoSerial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

  while(Serial.available()>0){
    input[i]= Serial.read();
    if(input[i]!=';'){
        i++;
      }else{
        input[i]=0;
        analysisCommand(input);
      }
   }
     
}

void analysisCommand(char *inputCommand){
  int commandType=atoi(inputCommand[0]);        
  char* command=strchr(inputCommand,':');
  command++;
  switch (commandType){
    case 0: 
      servoSerial.write(command);
      Serial.write(command);
      break;
    case 1: 
      digitalWrite(LED_BUILTIN, atoi(command[0])); 
      break;
    default:break;
   }
}



